<template>
    <div>
        <header class="pr white" style="padding: 45px 0px 40px;">
            <img src="../../assets/images/7.jpg" class="displayB centerauto shadowB" style="max-width: 70%;margin: 0px auto;padding: 10px;background: #fff;" />
        </header>
        <van-cell-group>
            <van-field label="支付密码：" type="password" maxlength="6" v-model="password" placeholder="请输入支付密码" />
            <van-field label="确认密码：" type="password" maxlength="6" v-model="confirm_password" placeholder="再次输入密码" />
        </van-cell-group>
        <div class="text-center margin_t50">
            <van-button type="primary" class="width_80p btn_size_40" @click="onSubmit">确 定</van-button>
        </div>
    </div>
</template>
<script>

    import '@/assets/css/main.css'
    export default {
        data(){
            return{
                password: '',
                confirm_password: '',
            }
        },
        methods: {
            onSubmit(){
                var _this = this;
                
                if(!this.password){
                    _this.$toast('请输入支付密码');
                    return;
                }
                if(!this.confirm_password){
                    _this.$toast('请输入确认密码');
                    return;
                }
                //两次密码的校验
                if(this.password != this.confirm_password){
                    _this.$toast('两次密码输入不一致');
                    return;
                }

                this.$httpPost('/api/index/Personal_center/addPaymentPassword',{
                    'u_id': window.localStorage.u_id,
                    'password': this.password,
                    'confirm_password': this.confirm_password,
                }).then(response => {
                    
                    if(response.code == 200){

                        _this.$toast(response.msg);

                        setTimeout(() => {
                            _this.$router.push({
                                path: '/home',
                            });
                        }, 2000);
                    }else{
                        
                        _this.$toast(response.msg);
                    }

                });
            },
        },
        mounted(){
            
        },
    }
</script>